package com.szpx.service.impl;

import com.szpx.entity.ZJH.DriverReservation;
import com.szpx.mapper.DriverReservationMapper;
import com.szpx.service.DriverReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;

@Service
public class DriverReservationServiceImpl implements DriverReservationService {

    @Resource
    private DriverReservationMapper driverReservationMapper;

    @Override
    public DriverReservation getById(String id) {
        return driverReservationMapper.selectById(id);
    }

    @Override
    public List<DriverReservation> getAll() {
        return driverReservationMapper.selectAll();
    }

    @Override
    public boolean add(DriverReservation reservation) {
//        reservation.setId();
        reservation.setId(UUID.randomUUID().toString().replace("-", ""));
        reservation.setStatus(DriverReservation.STATUS_NEW);
        return driverReservationMapper.insert(reservation) > 0;
    }

    @Override
    public boolean update(DriverReservation reservation) {
        return driverReservationMapper.update(reservation) > 0;
    }

    @Override
    public boolean delete(Integer id) {
        return driverReservationMapper.delete(id) > 0;
    }
}
